# name : gsDesign nSurv full
# key : gsDesign.nSurv.full
# key : gsDesign.nSurv.template
# expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil))
# contributor: Shuguang Sun
# --
# median control time-to-event
medianC <- ${1:12}
# exponential dropout rate per unit of time
eta <- ${2:0.001}
# hypothesized experimental/control hazard ratio
# (alternate hypothesis)
hr <- ${3:0.6}
# null hazard ratio (1 for superiority, >1 for non-inferiority)
hr0 <- ${4:1}
# Type I error (1-sided)
alpha <- ${5:0.025}
# Type II error (1-power)
beta <- ${6:0.1}
# study duration, NULL is to calcuate, otherwise gamma is relative
T <- ${7:NULL}
# follow-up duration of last patient enrolled
minfup <- ${8:5}
# enrollment period durations
R <- rep(1, 10)
# relative enrollment rates during above periods
gamma <- c(0.25, 0.25, 0.25, 0.50, 0.50, 0.50, 0.75, 0.75, 0.75, 1.00) * ${9:20}
# randomization ratio, experimental/control
ratio <- ${10:1}
nSurv(
  # Lachin and Foulkes (1986) method
  # (fixed trial duration, T and minfup, proportion to gamma)
  # Kim and Tsiatis(1990) method
  # (fixed enrollment rates and enrollment duration/minimum follow-up)
  lambdaC = log(2) / medianC,
  hr = hr,
  hr0 = hr0,
  R = R,
  gamma = gamma,
  eta = eta,
  minfup = minfup,
  T = T,
  beta = beta,
  alpha = alpha)
